﻿/*
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <unistd.h>
#include <pthread.h>

#include "poolsocket.h"

int main346(void)
{
	char* ip = "127.0.0.1";
	int port = 8080;
	//int connecttime = 3;
	int time = 3;
	int connfd = -1;

	int ret = -1;

	unsigned char* data = "abcdefg";
	int datalen = 5;

	unsigned char* out = NULL;
	int outlen = -1;

	//1.客户端，初始化；
	ret = sckClient_init();
	if (ret != 0)
	{
		printf("sckClient_init error %d\n", ret);
		return ret;
	}

	while (1)
	{
		//2.客户端，连接服务器；
		//ret = sckClient_connect(ip, port, connecttime, &connfd);
		ret = sckClient_connect(ip, port, time, &connfd);
		if (ret == Sck_ErrTimeOut)
		{
			printf("----客户端连接服务器-超时 \n");
			continue;
		}
		else if (ret != 0)
		{
			printf("客户端连接服务器-失败：errorNO: %d\n", ret);
			break;
		}

		//4.客户端，发送报文；
		ret = sckClient_send(connfd, time, data, datalen);
		if (ret == Sck_ErrPeerClosed)
		{
			//7.检测到，对（方）端关闭，则关闭本端；
			//sckServer_close(connfd);
			//printf("---ErrPeerClosed \n");
			printf("---服务器关闭，客户端断开连接 \n");
			//return NULL;
			break;
		}
		else if (ret == Sck_ErrTimeOut)
		{
			//8.一般在并发访问量较高时，才会出现这样的情况；
			//printf("---服务器检测到本端发送数据-超时 \n");
			printf("----服务器接收数据-超时 \n");
			//return NULL;
			continue;
		}
		else if (ret != 0)
		{
			//printf("未知错误\n");
			printf("客户端发送数据失败：errorNO: %d\n", ret);
			//return NULL;
			break;
		}
		sleep(1);

		//5.客户端，接收报文；1
		ret = sckClient_rev(connfd, time, &out, &outlen);
		if (ret == Sck_ErrPeerClosed)
		{
			//9.检测到，对（方）端关闭，则关闭本端；
			//sckServer_close(connfd);
			//printf("---ErrPeerClosed \n");
			printf("---服务器关闭，客户端断开连接 \n");
			//return NULL;
			break;
		}
		else if (ret == Sck_ErrTimeOut)
		{
			//10.一般在并发访问量较高时，才会出现这样的情况；
			//printf("---服务器检测到本端发送数据-超时 \n");
			//printf("----服务器接收数据-超时 \n");
			printf("----服务器发送数据-超时 \n");
			//return NULL;
			continue;
		}
		else if (ret != 0)
		{
			//printf("未知错误\n");
			//printf("客户端发送数据失败：errorNO: %d\n", ret);
			printf("客户端接收数据失败：errorNO: %d\n", ret);
			//return NULL;
			break;
		}

	}
	if (connfd != -1)
	{
		//3.客户端，关闭和服务端的连接；
		int sckClient_closeconn(int connfd);
	}

	//6.客户端，释放；
	sckClient_destroy();

	return 0;
}
*/